home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- Smaller Installer © 1995 Bill Goodman, All Rights Reserved
- *******************************************************************************
-
- Test Gestalt Example
-
- This installer hook procedure demonstrates using a Gestalt call to test a
- system feature and enable one of two installation groups based on the result.
- In this example, the hook enables group "O" if the system software version is
- less than 7.1 and enable group "P" if the version is 7.1 or higher.
-
- To build this hook procedure, compile this code and create a code resource
- (Type:SICR, ID:501, non-preloaded, nonpurgeable, unlocked, unprotected,
- non-sysheap). Add this resource to the "TestGestaltHook.rsrc" file. Copy all
- the resources in "TestGestaltHook.rsrc" to your installer's resource file.
-
- ******************************************************************************/
-
- // This file is compatible with version 2.1 of the universal headers
- #include <GestaltEqu.h>
-
- #ifdef __MWERKS__
- #include <A4Stuff.h>
- #endif
-
- #ifdef THINK_C
- #include <SetUpA4.h>
- #endif
-
- #include "SIHookProc.h"
-
-
- /******************************************************************************
- Function Prototypes
- ******************************************************************************/
- void FirstFunction(void);
-
-
- /******************************************************************************
- Constant Definitions
- ******************************************************************************/
- #define groupOMask 0x4000 // Group "O" selection mask
- #define groupPMask 0x8000 // Group "P" selection mask
-
-
- /******************************************************************************
- Variable Definitions
- ******************************************************************************/
- SIHookParmBlk *gParms; // Global pointer to parameter block
-
-
- /*****************************************************************************/
- pascal void main(
- SIHookParmBlk *parmBlk // Pointer to parameter block
- )
- /******************************************************************************
- This is the main entry point for the installer hook procedure.
- ******************************************************************************/
- {
- #ifdef __MWERKS__
- long holdA4;
- #endif
-
- // Set up access to global variables
- #ifdef THINK_C
- RememberA0();
- SetUpA4();
- #endif
-
- #ifdef __MWERKS__
- holdA4 = SetCurrentA4();
- #endif
-
- gParms = parmBlk;
-
- switch (gParms->function)
- {
- case siHookFirst:
- FirstFunction();
- break;
- }
-
- // Restore original A4 value
- #ifdef THINK_C
- RestoreA4();
- #endif
-
- #ifdef __MWERKS__
- SetA4(holdA4);
- #endif
- }
-
-
- /*****************************************************************************/
- void FirstFunction(void)
- /******************************************************************************
- Input parameters:
- "targetVRefNum" Volume reference number of target volume
- "groupAPFlags" Groups currently selected
- "groupQUSel"
- "groupVZSel"
- "group32Flags"
- "group64Flags"
- "group96Flags"
- "groupEnvironFlags"
-
- Returns:
- "groupAPFlags" Updated installation groups
- "groupQUSel"
- "groupVZSel"
- "group32Flags"
- "group64Flags"
- "group96Flags"
- "result" Hook result code (siHookNoErr, siHookQuit)
-
- This function is called once when the installer is launched.
- ******************************************************************************/
- {
- OSErr error;
- long feature;
-
- gParms->groupAPFlags &= ~(groupOMask | groupPMask); // Clear both flags
-
- // Use Gestalt to obtain system version. Assume < 7.1 if Gestalt fails.
- error = Gestalt(gestaltSystemVersion, &feature);
- if (!error && (feature >= 0x0710))
- gParms->groupAPFlags |= groupPMask; // 7.1 or higher
- else
- gParms->groupAPFlags |= groupOMask; // Lower than 7.1
- }
-